package com.ibeeking.found.cms.service.common.constants.enums;

import com.ibeeking.nematos.utils.data.StringUtils;

/**
 * @Author ibeeking
 * @Date: 2021-01-05 19:15
 * @Description: PagePublishStatusEnum
 */
public enum PageOperTypeEnum {
    /**
     * 1=保存未草稿
     */
    SAVE_DRAFT(1, "保存为草稿"),
    /**
     * 2=保存并发布
     */
    SAVE_AND_PUBLISH(2, "保存并发布"),
    /**
     * 3=发布
     */
    PUBLISH(3, "发布"),
    /**
     * 3=发布
     */
    SAVE_AS_TEMPLATE(4, "保存为模板"),
    /**
     * 3=发布
     */
    PREVIEW(5, "预览"),
    ;

    private Integer code;
    private String desc;

    PageOperTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(Integer code) {
        for (PageOperTypeEnum enumObj : values()) {
            if (enumObj.getCode().equals(code)) {
                return enumObj.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static PageOperTypeEnum getEnum(Integer code) {
        for (PageOperTypeEnum enumObj : values()) {
            if (enumObj.getCode().equals(code)) {
                return enumObj;
            }
        }
        return null;
    }
}
